// Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:async' show Future, StreamController;
import 'dart:convert' show JSON;
import 'dart:io' show Directory, File, stdout;
import 'template_data.dart';
import 'templates.dart';
import 'package:loyhd/config.dart';

class HtmlGeneratorInstance{
  final Templates _templates;

  HtmlGeneratorInstance(this._templates);

  String generate(int pageIndex) {
    switch(pageIndex){
      case PAGE_INDEX.INDEX:
        return generateIndex();
    }
  }

  String generateIndex() {
    IndexTemplateData data = new IndexTemplateData();
    return _build('index.html', _templates.indexTemplate, data);
  }

  String _build(String filename, TemplateRenderer template, var data) {
    String content = template(data,
        assumeNullNonExistingProperty: false, errorOnMissingProperty: true);
    return content;
  }
}
